package com.aaa.doctor.controller.api;

import com.aaa.doctor.service.RegistrationService;
import com.aaa.doctor.vo.RegistrationVo;
import com.aaa.entity.Registration;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/doctor/api/registration")
public class ApiRegistrationController {

    @Autowired
    private RegistrationService registrationService;

    /**
     * 查询所有挂号信息
     * @param currentPage
     * @param pageSize
     * @param registrationVo
     * @return
     */
    @PostMapping("/getAllInfo/{currentPage}/{pageSize}")
    public Result<IPage<Registration>> getAllInfo(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody RegistrationVo registrationVo){
        return registrationService.getAllInfo(currentPage,pageSize,registrationVo);
    }

    /**
     * 收费和退号
     * 获取被收费人的registrationId
     * registrationId ---> 修改status
     * @param registrationId
     * @return
     */
    @GetMapping("/getStatus/{registrationId}")
    public Result<String> getStatus(@PathVariable String registrationId){
        return registrationService.updByrIdStatus(registrationId);
    }

    /**
     * 作废
     * 获取被收费人的registrationId
     * registrationId ---> 修改status
     * @param registrationId
     * @return
     */
    @GetMapping("/getVoid/{registrationId}")
    public Result<String> getVoid(@PathVariable String registrationId){
        return registrationService.updStatus(registrationId);
    }

    /**
     * 查询待就诊的所有信息
     * @return
     */
    @GetMapping("/getWaitSchedulingType/{schedulingType}")
    public Result<List<Registration>> getWaitSchedulingType(@PathVariable String schedulingType){
        return registrationService.getWaitSchedulingType(schedulingType);
    }

    /**
     * 查询就诊中的所有信息
     * @return
     */
    @GetMapping("/getVisitingSchedulingType/{schedulingType}")
    public Result<List<Registration>> getVisitingSchedulingType(@PathVariable String schedulingType){
        return registrationService.getVisitingSchedulingType(schedulingType);
    }

    /**
     * 查询就诊完成的所有信息
     * @return
     */
    @GetMapping("/getFinishSchedulingType/{schedulingType}")
    public Result<List<Registration>> getFinishSchedulingType(@PathVariable String schedulingType){
        return registrationService.getFinishSchedulingType(schedulingType);
    }

    /**
     * 接诊，更新挂号的状态为就诊中
     * @param registrationId
     * @return
     */
    @PostMapping("/updSchedulingType/{registrationId}")
    public Result<String> updSchedulingType(@PathVariable String registrationId){
        return registrationService.updSchedulingType(registrationId);
    }

    /**
     * 新开就诊页面
     * 完成就诊 -- 更改状态为就诊完成
     * @param registrationId
     * @return
     */
    @PostMapping("/updvisitCompleteSchedulingType/{registrationId}")
    public Result<String> updvisitCompleteSchedulingType(@PathVariable String registrationId){
        return registrationService.updvisitCompleteSchedulingType(registrationId);
    }

    /**
     * 查询收费是否成功
     * @param registrationId
     * @return
     */
    @GetMapping("/getRegId/{registrationId}")
    public Result getRegId(@PathVariable String registrationId){
        return registrationService.getRegId(registrationId);
    }
}
